package org.raymond.iworks.study.basic.designpattern.iterator;

import java.util.Iterator;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class ComputerCollegeIterator implements Iterator {
    private Department[] departments;
    private int idx;

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if(idx>=departments.length || departments[idx]==null){
            return false;
        }else return true;
    }

    @Override
    public Object next() {
        Department department = departments[idx];
        idx++;
        return department;
    }

    @Override
    public void remove() {
        Iterator.super.remove();
    }
}
